#include <cutils/memory.h>
#include <utils/Log.h>
#include <binder/IPCThreadState.h>
#include <binder/ProcessState.h>
#include <binder/IServiceManager.h>
#include <gui/Surface.h>
#include <gui/SurfaceComposerClient.h>
#include <gui/ISurfaceComposer.h>

using namespace android;

int main(int argc, char** argv)
{
	
#if 0  
    //could not compile
	//创建线程池
	sp< ProcessState> proc(ProcessState::self());
	ProcessState::self()->startThreadPool();
	//创建surfaceflinger的客户端
	sp< SurfaceComposerClient> client=new SurfaceComposerClient(); 
	//也即“LayerBuffer”模式的Layer
	sp< Surface> surface=client->createSurface(getpid(), 0, 320, 240,PIXEL_FORMAT_UNKNOWN, ISurfaceComposer::ePushBuffers);
	sp< ISurface> isurface=surface::getISurface(surface);
	printf("isurface=%p\n", isurface.get());
	sp< OverlayRef> ref=isurface->createOverlay(320, 240, PIXEL_FORMAT_RGB_565);
	sp< Overlay> overlay=new Overlay(ref);    //创建Overlay对象
	overlay_buffer_t buffer; 
	overlay->dequeueBuffer(&buffer);
	printf("buffer=%p\n", buffer);
	void* address=overlay->getBufferAddress(buffer);
	printf("address=%p\n", address); //在此操作Overlay的地址，执行想要的操作
	overlay->queueBuffer(buffer);
#endif
    	return 0;
}